package com.kk.flyweight;

/**
 * @author 王志强
 * @date 2022-01-06
 */
public class Client {
    public static void main(String[] args) {

        WebSiteFactory webSiteFactory = new WebSiteFactory();

        WebSite webSite = webSiteFactory.getWebSiteCategory("新闻");
        WebSite webSite1 = webSiteFactory.getWebSiteCategory("blog");
        WebSite webSite2 = webSiteFactory.getWebSiteCategory("blog");

        User user = new User();
        user.setUsername("阿伟");
        webSite.use(user);

        user.setUsername("阿aaaaa");
        webSite1.use(user);

        user.setUsername("阿bbbbb");
        webSite2.use(user);


        System.out.println("pool中的实例数: " + webSiteFactory.poolSize());

    }
}
